<?php

/**
 * Created by PhpStorm.
 * User: fang
 * Date: 2017/11/20
 * Time: 上午10:19
 */
class ProgramAudit
{
    const API_HOST = 'https://api.weixin.qq.com';
    const API_GET_PAGE = '/wxa/get_page';

    public function __construct($appid,$web_id){
        $this->appid = $appid;
        $this->web_id = $web_id;
//        $this->access_token = $this->get_authorizer_access_token();
    }
    public function get_page($access_token){
        return 2222;
    }
    static public function request($url = '',$data = [],$method = 'POST', $timeout = 10){
        if(empty($url) || empty($data) || $timeout <= 0){
            return false;
        }
        if($method == 'GET' && is_array($data)){
            $url = $url . '?' . http_build_query($data);
        }
        $con = curl_init((string)$url);
        curl_setopt($con, CURLOPT_HEADER, false);
        if($method == 'POST'){
            curl_setopt($con, CURLOPT_POSTFIELDS, $data);
        }
        curl_setopt($con, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($con, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($con, CURLOPT_POST, true);
        curl_setopt($con, CURLOPT_RETURNTRANSFER,true);
        curl_setopt($con, CURLOPT_TIMEOUT, (int)$timeout);

        return curl_exec($con);
    }
}